#{extends 'common/supervisor.html' /}
#{set title:'系统管理员列表' /}
<div class="xn_c_contentwarp">
  <div class="xn_c_contentlist">
  #{include "supervisor/systemSettings/common/leftBar.control"/}
  <div class="xn_c_content">
    <div class="xf_ht_tablelist">
      #{form @supervisor.systemSettings.supervisorAction.list(), id:'list'}
      <input type="hidden" id="currPage" name="currPage"/>
	  <input type="hidden" id="pageSize" name="pageSize"/>
      <!-- 搜索 -->
      <div class="xf_ht_search_inon">
      <div class="xf_ht_search_r">
        <div class="xf_ht_search_xl">
        <input type="text" class="search_w" name="keyword" id="keyword" placeholder="账号/真实姓名/手机1/邮箱" value="${pageBean.conditions.keyword}" style="width:150px">
        </div>
        <div class="xf_ht_search_xl">
        <input type="submit" class="search_button" value="搜索">
        </div>
      </div>
      </div>
      #{/form}
      <!-- 列表内容 -->
      <div class="xn_c_content_top">
      #{table class:"xn_c_content_list", cellspacing:"0", cellpadding:"0", border:"0", tr_class_odd:"xn_tr_bj"}
      #{tr}
        #{th width:"100px"}序号#{/th}
        #{th width:"100px"}管理员账号#{/th}
        #{th width:"100px"}真实姓名#{/th}
        #{th width:"100px"}云盾编号#{/th}
        #{th width:"100px"}创建日期#{/th}
        #{th width:"100px"}管理员等级#{/th}
        #{th width:"400px"}权限组#{/th}
        #{th width:"100px"}手机1#{/th}
        #{th width:"100px"}邮箱#{/th}
        #{th width:"100px"}操作#{/th}
      #{/tr}
      #{list pageBean?.page}         
      #{tr tr_index:_index}
        #{td}${(pageBean?.currPage - 1)*pageBean?.pageSize + _index}#{/td}
        #{td}${_?.name}#{/td}
        #{td}${_?.reality_name}#{/td}
        #{td}${_?.ukey}#{/td}
        #{td}${_?.time?.format("yyyy-MM-dd HH:mm:ss")}#{/td}
        #{td}
          #{if _?.level == 0}
                                       普通管理员
          #{/if}
          #{if _?.level == 1}
                                       超级管理员
          #{/if}
        #{/td}
        #{td}${_?.right_group}#{/td}
        #{td}${_?.mobile1}#{/td}
        #{td}${_?.email}#{/td}
        #{td}
          #{if _?.id == 1}
          <span><a href="javascript:showDetailWindow('${_?.sign}')" class="xf_ta_onclick">详情</a></span>
          #{/if}
        #{else}
        <span><a href="javascript:editSupervisorInit('${_?.sign}');" class="xf_ta_onclick">编辑</a></span>
        <span><a href="javascript:showRightsWindow('${_?.sign}')" class="xf_ta_onclick">权限</a></span>
        #{if _?.is_allow_login == true}
        <span><a href="javascript:enable('${_?.sign}', false)" id="enable${_?.sign}" class="xf_ta_onclick">锁定</a></span>
        #{/if}
        #{else}
        <span><a href="javascript:enable('${_?.sign}', true)" id="enable${_?.sign}" class="xf_ta_onclick">启用</a></span>
        #{/else}
        <span><a href="@{resetPassword(_?.sign, pageBean.currPage, pageBean.pageSize)}" class="xf_ta_onclick">重置密码</a></span>
        <span><a href="javascript:deleteSupervisor('${_?.sign}')" id="delete" class="xf_ta_onclick">删除</a></span>
        #{/else}
        #{/td}
      #{/tr}
      #{/list}
      #{/table}
      </div>
      <!-- 列表底部 -->
      <div class="xn_c_content_bottom">
        #{page currPage:pageBean.currPage,pageSize:pageBean.pageSize,totalCount:pageBean.totalCount,theme:2,style:4}
          keyword=${pageBean.conditions.keyword}#{/page}
        <input id="xf_dfk_fkzh_tcc3" type="button" class="xf_htbutton" onclick="createSupervisorInit();" value="添加管理员">
      </div>
      </div>
    </div>
  </div>
</div>

<!-- 详情-弹出层 -->
<div class="xf_ht_ttc" id="xf_ht_fkzh_ttc">
</div>

<!-- 权限-弹出层 -->
<div class="xn_c_ban_jox" id="xf_ht_fkzh_ttc2" style="display:none;height:400px;overflow:auto;">
</div>

<!-- 添加管理员-弹出层 -->
<div class="xn_c_ban_jox" id="xf_ht_tjgly_ttc" style="display:none;height:400px;overflow:auto;">
</div>

<!-- 编辑管理员-弹出层 -->
<div class="xn_c_ban_jox" id="xf_ht_bjgly_ttc" style="display:none;height:400px;overflow:auto;">
</div>

<!-- 设置管理员权限组-弹出层 -->
<div class="xf_ht_ttc" id="xf_ht_szqxz_ttc">
</div>

<script type="text/javascript">
  function showPage(currPage, pageSize){
    $("#currPage").val(currPage);
    $("#pageSize").val(pageSize);
    $("#list").submit();
  }
  $(function() {
    /* 高亮显示 */
	  showHighLight(3,3,10);
  });

  //详情
  function showDetailWindow(sign) {
    $.ajax({
      url : "@{supervisor.systemSettings.supervisorAction.detail()}",
      type : "POST",
      data : {
        "sign" : sign
      },
      success : function(data) {
        if (data.code < 0) {
          alert(data.msg);
          
          return;
      }
      
      var ttc = $("#xf_ht_fkzh_ttc");
      ttc.html(data);
      $.layer({
        type: 1,
        area: ['500', 'auto'],
        title: '管理员详情',
        page: {dom : ttc}
      });
        //showDiv(ttc);
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }
  
  var p2p,ps,pt;
  //添加管理员
  function createSupervisorInit() {
    $.ajax({
      url : "@{supervisor.systemSettings.supervisorAction.createSupervisorInit()}",
      type : "POST",
      data : {
      },
      success : function(data) {
        if (data.code < 0) {
          alert(data.msg);
          
          return;
        }
      
        var ttc = $("#xf_ht_tjgly_ttc");
        ttc.html(data);
        $.layer({
          type: 1,
          area: ['610', 'auto'],
          title: '添加管理员',
          page: {dom : ttc}
        });
        //showDiv(ttc);
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }
  
  //编辑管理员
  function editSupervisorInit(sign) {
    $.ajax({
      url : "@{supervisor.systemSettings.supervisorAction.editSupervisorInit()}",
      type : "POST",
      data : {
        "sign" : sign
      },
      success : function(data) {
        if (data.code < 0) {
          alert(data.msg);
          
          return;
        }
      
        var ttc = $("#xf_ht_bjgly_ttc");
        ttc.html(data);
        $.layer({
          type: 1,
          area: ['610', 'auto'],
          title: '编辑管理员',
          page: {dom : ttc}
      });
        //showDiv(ttc);
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }
  
  //权限
  function showRightsWindow(sign) {
     $.ajax({
      url : "@{supervisor.systemSettings.supervisorAction.setRightsInit()}",
      type : "POST",
      data : {
        "sign" : sign
      },
      success : function(data) {
        if (data.code < 0) {
          alert(data.msg);
          
          return;
        }
      
        var ttc = $("#xf_ht_fkzh_ttc2");
        ttc.html(data);
        $.layer({
          type: 1,
          area: ['718', 'auto'],
          title: '权限设置',
          page: {dom : ttc}
      });
        //showDiv(ttc);
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }
  
  //锁定/启用
  function enable(sign, isAllowLogin) {
    $.ajax({
      url : "@{supervisor.systemSettings.supervisorAction.enable()}",
      type : "POST",
      data : {
        "sign" : sign,
        "isAllowLogin" : isAllowLogin
      },
      success : function(data) {
        if (data.code < 0) {
          alert(data.msg);
          
          return;
        }
      
        if (isAllowLogin) {
          $("#enable"+sign).html("锁定");
          $("#enable"+sign).attr("href","javascript:enable('"+sign+"', false)");
        } else {
          $("#enable"+sign).html("启用");
          $("#enable"+sign).attr("href","javascript:enable('"+sign+"', true)");
        }
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }
  
  //删除管理员
  function deleteSupervisor(sign) {
    if (!confirm("确认要删除？")) {
            return;
        }
    
    $.ajax({
      url : "@{supervisor.systemSettings.supervisorAction.deleteSupervisor()}",
      type : "POST",
      data : {
        "sign" : sign
      },
      success : function(data) {
        alert(data.msg);
        
        if (data.code == 0) {
          location.reload();
        }
      },
      error : function() {
        alert("对不起，出现错误!");
      }
    });
  }
  
  //搜索
  function search() {
    window.location.href = "list?keyword=" + encodeURIComponent($("#keyword").val());
  }
</script>
